package cn.minsh.lims.eoms.modules.app.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import cn.minsh.lims.eoms.modules.app.entity.PlanScopeEntity;
import cn.minsh.lims.eoms.modules.app.service.PlanScopeService;
import cn.minsh.lims.eoms.common.utils.PageUtils;
import cn.minsh.lims.eoms.common.utils.R;



/**
 * 巡检计划范围（巡检计划和巡检范围关联表）
 *
 * @author lht
 * @email sunlightcs@gmail.com
 * @date 2021-04-30 10:36:13
 */
@RestController
@RequestMapping("sys/planScope")
public class PlanScopeController {
    @Autowired
    private PlanScopeService planScopeService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("app:planscope:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = planScopeService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("app:planscope:info")
    public R info(@PathVariable("id") Long id){
		PlanScopeEntity planScope = planScopeService.getById(id);

        return R.ok().put("planScope", planScope);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("app:planscope:save")
    public R save(@RequestBody PlanScopeEntity planScope){
		planScopeService.save(planScope);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("app:planscope:update")
    public R update(@RequestBody PlanScopeEntity planScope){
		planScopeService.updateById(planScope);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("app:planscope:delete")
    public R delete(@RequestBody Long[] ids){
		planScopeService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
